# 解析NCBI Taxonomy物种详细的层级关系，构建一份物种层级信息总表

open I,"cut -f 1,3,5 nodes.dmp|";
while(<I>){
	chomp;
	@a=split/\t/;
	$Dad{$a[0]}=$a[1];
	$Level{$a[0]}=$a[2];
}
close I;

foreach (keys %Level){
	$x=$_;
	$Detail{$_}=$Level{$x};
	while($Dad{$x} ne '1'){
		$Detail{$_}.="\-$Dad{$x}:$Level{$Dad{$x}}";
		$x=$Dad{$x};
	}
}

open I,"grep \"scientific\ name\" names.dmp|cut -f 1,3|";
while(<I>){
	chomp;
	@a=split/\t/;
	@b=split/\-/,$Detail{$a[0]};
	$N=scalar(@b);
	print "$_\t$N\t$Detail{$a[0]}\n";
}
close I;